package com.youi.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.youi.common.Common;
import com.youi.common.DelStatus;
import com.youi.dao.ActivityDao;
import com.youi.entity.Activity;
import com.youi.entity.Activitygoods;
import com.youi.entity.Goods;
import com.youi.service.ActivityService;
import com.youi.service.ActivitygoodsService;
import com.youi.service.GoodsService;

@Service
public class ActivityServiceImpl extends BaseServiceImpl<Activity> implements ActivityService{
		
		private ActivityDao activityDao;
		
		
		@Autowired
		private GoodsService goodsService;
		@Autowired
		private ActivitygoodsService activitygoodsService;
		@Autowired
		public void setfaultRecordDao(ActivityDao activityDao){
			this.activityDao=activityDao;
			super.setBaseDAO(activityDao);
		}

		@Override
		public void delActivityGoodsByActId(Activity activity) {
			// TODO Auto-generated method stub
			if (activity!=null) {
				Map<String, Object> params=new HashMap<String, Object>();
				params.put(Common.DELSTATUS, DelStatus.NODEL);
				params.put("activityId", activity.getId());
				List<Activitygoods> activitygoodsList=activitygoodsService.getByParams(params);
				if (activitygoodsList!=null&&activitygoodsList.size()>0) {
					for (Activitygoods activitygoods : activitygoodsList) {
						activitygoods.setDelStatus(DelStatus.NODEL);
					}
					activitygoodsService.saveOrUpdateAll(activitygoodsList);
				}				
			}
		}

	
}